﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ecommerce.Areas.Manager.Models;
using System.Web.Security;
using Ecommerce.Common;

namespace Ecommerce.Areas.Manager.Controllers
{
    public class LoginController : Controller
    {
        //
        // GET: /Manager/Login/

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Login(Login login)
        {
            if (!EConst.ADMIN_USERNAME.Equals(login.Username) || !EConst.ADMIN_PASSWORD.Equals(login.Password))
            {
                ViewBag.ErrorMsg = "Login failed!";
                return View("Index", login);
            }
            else
            {
                FormsAuthentication.SetAuthCookie(login.Username, false);
                return RedirectToAction("Index", "Product");
            }
        }

    }
}
